//
//  MainTabbarViewController.m
//  Lucky28
//
//  Created by zr on 2018/7/31.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "MainTabbarViewController.h"
#import "ReadViewController.h"
#import "CircleViewController.h"
#import "PictureViewController.h"
#import "MyselfViewController.h"
#import "MainViewController.h"

@interface MainTabbarViewController ()

@end

@implementation MainTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI{
    
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
    
    [UITabBar appearance].translucent = NO;
    
    ReadViewController * readVC = [ReadViewController new];
    readVC.title = @"阅读";
    
    CircleViewController * circleVC = [CircleViewController new];
    circleVC.title = @"圈子";
    
    PictureViewController * pictureVC = [PictureViewController new];
    pictureVC.title = @"照片墙";
    
    MyselfViewController * myselfVC = [MyselfViewController new];
    myselfVC.title = @"个人中心";
    
    
    MainViewController * readNav = [[MainViewController alloc] initWithRootViewController:readVC];
    MainViewController * circleNav = [[MainViewController alloc] initWithRootViewController:circleVC];
    MainViewController * pictureNav = [[MainViewController alloc] initWithRootViewController:pictureVC];
     MainViewController * myselfNav = [[MainViewController alloc] initWithRootViewController:myselfVC];
    
    readNav.tabBarItem.image = [[UIImage imageNamed:@"yuedu"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    readNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"yuedu1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    circleNav.tabBarItem.image = [[UIImage imageNamed:@"quanzi"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    circleNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"quanzi1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    pictureNav.tabBarItem.image = [[UIImage imageNamed:@"zhaopianqiang"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    pictureNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"zhaopianqiang1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    myselfNav.tabBarItem.image = [[UIImage imageNamed:@"gerenzhongxin"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    myselfNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"gerenzhongxin1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    //改变tabbarController 文字选中颜色(默认渲染为蓝色)
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:ColorWithRGB(0xf52f4c)} forState:UIControlStateSelected];
    
    //创建一个数组包含四个导航栏控制器
    NSArray *vcArry = [NSArray arrayWithObjects:readNav,circleNav,pictureNav,myselfNav,nil];
    
    //将数组传给UITabBarController
    self.viewControllers = vcArry;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
